function [errs inv_errs] = reformatUncertainty(e)
switch length(size(e))
    case 2
        [N D] = size(e);
        errs = zeros(D, D, N);
        for i = 1:N
            errs(:, :, i) = diag(e(i, :));
        end
        
        if nargout > 1
            inv_errs = zeros(D, D, N);
            for i = 1:N
                inv_errs(:, :, i) = diag(1./e(i, :));
            end
        end

    case 3
        [D D N] = size(e);
        errs = zeros(D, D, N);
        for i = 1:N
            errs(:, :, i) = e(:, :, i);
        end
        
        if nargout > 1
            inv_errs = zeros(D, D, N);
            for i = 1:N
                inv_errs(:, :, i) = inv(e(:, :, i));
            end
        end
        
    otherwise
        error('Unknown error type', 'Unknown error type');
end
